<html>
    <meta charset="utf-8">
    <body>
<?php
  $student_name=$_POST['stname']; 
  $liuyan=$_POST['student_text']; 

  $openid= $_POST['wxid'];
  $link=mysqli_connect(SAE_MYSQL_HOST_M.':'.SAE_MYSQL_PORT,SAE_MYSQL_USER,SAE_MYSQL_PASS);
  mysqli_select_db($link,"app_formtest1");
  if (!$link)
  {
	die('Could not connect: ' . mysql_error());
  };

  $result=mysqli_query($link,"select * from weixin_students where student_name=$student_name");
 
  $l=mysqli_num_rows($result);

  if($l){
  	 $row=mysqli_fetch_object($result);
     $name= $row->student_name;
     
     echo "学生姓名：".$student_name."<br>";

$kv1 = new SaeKV();
// 初始化KVClient对象
$ret1 = $kv1->init();
      $key1 = $_POST['wxid'];
      $myinfo1 = $student_name;
      $kv1->set($key1,$myinfo1);//将我的信息的数组写到KVDB中
//然后再取出来
$myinfo_inkvdb1 = $kv1->get($key1);
      //var_dump($myinfo_inkvdb);
     
     mysqli_query($link,"insert into weixin_students(student_name,stduent_text) values($student_name,$liuyan)");
      

      echo "<br><h3>留言成功</h3>";
  }
   else{
       echo "<h3>无此考生</h3>";

  };

mysqli_close($link);
?>
    </body>
</html>